import Vue from 'vue'
import './cube-ui'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import VueAxios from 'vue-axios'
import Cube from 'cube-ui'
import Vant  from 'vant'
import 'vant/lib/index.css'
import './assets/font/iconfont.css'
import 'amfe-flexible'
import Axios from 'axios'


Vue.use(Cube)
Vue.use(Vant)
Vue.use(VueAxios,axios);
Vue.config.productionTip = false

Axios.defaults.baseURL = 'http://www.tp5.com';
Axios.defaults.timeout = 8000;


axios.interceptors.request.use(
  config => {
  // 判断是否存在token，如果存在的话，则每个http header都加上token
    let token = localStorage.getItem('userId')
    if (token) {
        config.headers.token = token;
    }
    return config;
  },
  error => {
    return Promise.reject(error);
  });

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
